import {defineConfig} from 'vite'
import vue from '@vitejs/plugin-vue'
// import { visualizer } from "rollup-plugin-visualizer"

// ElementPlus组件按需导入（包含其图标）
import AutoImport from 'unplugin-auto-import/vite'

// SVG图标
import UnpluginSvgComponent from 'unplugin-svg-component/vite'

// 配置绝对路径别名@
import path from 'path'

// https://vite.dev/config/
export default defineConfig({
  resolve: {
    alias: {
      // 配置绝对路径别名@
      '@': path.resolve(__dirname, 'src'),
      'art-template': 'art-template/lib/template-web.js',
      'dot': 'dot/doT.js',
    },
  },

  plugins: [
    vue(),
    // visualizer({
    //   open: true
    // }),
    AutoImport({
      imports: ['vue'], // 自动导入 Vue 相关函数，如：ref, reactive, toRef 等
    }),

    // 解决IconsResolver无法动态引入图标的问题
    // https://github.com/Jevon617/unplugin-svg-component
    UnpluginSvgComponent({
      iconDir: ['src/assets/icons',
        'src/assets/icons/database',
        'src/assets/icons/language',
        'src/assets/icons/menu',
        'src/assets/icons/tool'],
      preserveColor: '',
      treeShaking: false
    })
  ],

  css: {
    preprocessorOptions: {
      scss: {
        // The legacy JS API is deprecated and will be removed in Dart Sass 2.0.0
        api: 'modern'
      }
    }
  },

  test: {
    isolate: false,
    // 你还可以仅对特定池禁用隔离
    poolOptions: {
      forks: {
        isolate: false,
      },
    },
    fileParallelism: false,
    pool: 'threads',
  },
})
